package cn.itcast.crm.service;

import cn.itcast.crm.domain.Customer;

import javax.ws.rs.*;
import java.util.List;

public interface CustomerService {

    /*
     @path:访问路径 全路径: web.xml配置路径/applicationcontext.xml配置路径/class上的@path/方法上的@path
           传递参数 @path("/customerservice/{参数1}/{参数2}")
           @pathparam("String") :接受路径传递的参数,匹配进方法 当参数名和{路径名}一致时,@pathparam直接使用即可
           @queryparam:基于restful风格传参方式 ?参数名=参数值&key=value
     @GET :     查询
     @POST:     保存
     @PUT:      修改
     @DELETE:   删除
     @Consumes 指定能够处理客户端传递过来数据格式
     @Produces 指定能否生成哪种格式数据返回给客户端
     */

    //查询所有未关联顾客
    @Path("/noassociationcustomer")
    @GET
    @Produces({"application/xml","application/json"})
    public List<Customer>findNoAssociationCustomers();


    //查询所有已关联顾客
    @Path("/associationfixedareacustomer/{fixedarea}")
    @GET
    @Produces({"application/xml","application/json"})
    public List<Customer>findHasAssociationCustomers(@PathParam("fixedarea") String fixedArea);


    //将指定id的顾客进行关联
    @Path("/associationcustomertofixedarea")
    @PUT
    public void associationCustomerToFixedArea(@QueryParam("customerIdStr")  String customerIdStr,
                                               @QueryParam("fixedAreaId") String fixedAreaId);
    @Path("/customer")
    @POST
    @Consumes({"application/xml","application/json"})
    public void  regist(Customer customer);
    //"http://localhost:8085/services/customerService/findbytelephone/"+model.getTelephone();
    //根据telephone 查询customer
    @Path("/findbytelephone/{telephone}")
    @GET
    @Produces({"application/xml","application/json"})
    @Consumes({"application/xml","application/json"})
    public Customer findByTelephone(@PathParam("telephone") String telephone);

    //http://localhost:8085/services/customerService/updatetype/" + model.getTelephone()
    //根据telephone将状态更新为1
    @Path("/updatetype")
    @PUT
    @Consumes({"application/xml","application/json"})
    public void updateType(String telephone);
    //根据电话和密码进行登录验证
    @Path("/login/{telephone}/{password}")
    @GET
    @Produces({"application/xml","application/json"})
    Customer login(@PathParam("telephone") String telephone,@PathParam("password") String password);
    //根据address查询fixedareaId
    @Path("/customer/getfixedareaid/{address}")
    @GET
    @Produces({"application/xml","application/json"})
    public String findFixedAreaIdByAddress(@PathParam("address") String address);
}
